<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('门店信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>门店状态：</label>
                            <select name="devDeploy" th:with="type=${@dict.getType('sys_store_dev_deploy')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 105px;">是否为连锁店：</label>
                            <select name="isChain" th:with="type=${@dict.getType('sys_store_is_chain')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <!--<li>-->
                        <!--<label>门店编码：</label>-->
                        <!--<input type="text" name="storeSn"/>-->
                        <!--</li>-->
                        <!--<li>-->
                        <!--<label>门店名称：</label>-->
                        <!--<input type="text" name="storeName"/>-->
                        <!--</li>-->
                        <!--<li>-->
                        <!--<label>直营合作商ID：</label>-->
                        <!--<input type="text" name="partnerId"/>-->
                        <!--</li>-->
                        <!--<li>-->
                        <!--<label>商户ID：</label>-->
                        <!--<input type="text" name="merchantId"/>-->
                        <!--</li>-->
                        <li class="select-time">
                            <label>签约时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="startTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="endTime"/>
                        </li>
                        <li>
                            <label style="width: 105px;">关键字查询字段：</label>
                            <select name="fields">
                                <option value="storeSn" selected>门店编码</option>
                                <option value="storeName">门店名称</option>
                                <option value="merchantName">直营商户姓名</option>
                                <option value="partnerName">直营合作商姓名</option>
                            </select>
                            <input type="text" name="keywords"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:store:add">-->
            <!--<i class="fa fa-plus"></i> 添加-->
            <!--</a>-->
            <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()"-->
            <!--shiro:hasPermission="system:store:edit">-->
            <!--<i class="fa fa-edit"></i> 修改-->
            <!--</a>-->
            <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"-->
            <!--shiro:hasPermission="system:store:remove">-->
            <!--<i class="fa fa-remove"></i> 删除-->
            <!--</a>-->
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:store:export">-->
            <!--<i class="fa fa-download"></i> 导出-->
            <!--</a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:store:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:store:remove')}]];
    var devDeployDatas = [[${@dict.getType('sys_store_dev_deploy')}]];
    var isChainDatas = [[${@dict.getType('sys_store_is_chain')}]];
    var storeContactsTypeDatas = [[${@dict.getType('sys_store_contacts_type')}]];
    var prefix = ctx + "system/store";


    var seeDetailFlag = [[${@permission.hasPermi('system:store:seeDetail')}]];


    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "门店信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'doorPhoto',
                    title: '门头照片',
                    formatter: function (value, row, index) {
                        if (value == null || value == "") {
                            return "-";
                        } else {
                            return $.table.imageView(value);
                        }
                    }
                },
                {
                    field: 'storeName',
                    title: '门店名称(状态)',
                    formatter: function (value, row, index) {
                        return value + "(" + $.table.selectDictLabel(devDeployDatas, row.devDeploy) + ")";
                    }
                },
                {
                    field: 'id',
                    title: '门店编码'
                },
                {
                    field: 'siteName',
                    title: '门店品类'
                },
                {
                    field: 'location',
                    title: '所在地区'
                },
                {
                    field: 'detailAddress',
                    title: '详细地址'
                },
                {
                    field: 'isChain',
                    title: '是否为连锁店',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isChainDatas, value);
                    }
                },
                {
                    field: 'partnerFullName',
                    title: '直营合作商'
                },
                {
                    field: 'merchantFullName',
                    title: '直营商户'
                },
                {
                    field: 'signingTime',
                    title: '签约时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];


                        // 查询直营合作商层级关系
                        actions.push('<a class="btn btn-default btn-xs ' + seeDetailFlag + '" href="javascript:void(0)" onclick="seeTier(\'' + row.partnerId + '\')"><i class="fa fa-navicon"></i>查看层级关系</a> ');


                        // 查看详情
                        actions.push('<a class="btn btn-primary btn-xs ' + seeDetailFlag + '" href="javascript:void(0)" onclick="seeDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');


                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function seeTier(id) {
        var prefix = ctx + "system/partner";
        var url = prefix + "/selectPartnerTree/" + id;
        var width = null;
        var height = null;
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
            width = 500;
        }
        if ($.common.isEmpty(height)) {
            height = 660;
        }
        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "合作商层级关系",
            content: url,
            btn: ['关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            cancel: function (index) {
                return true;
            }
        });
    }


    // 查看详情
    function seeDetail(id) {
        var url = prefix + "/seeDetail/" + id;
        var width = null;
        var height = null;
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
            width = 800;
        }
        if ($.common.isEmpty(height)) {
            height = 660;
        }
        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "查看门店详情",
            content: url,
            btn: ['关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            cancel: function (index) {
                return true;
            }
        });
    }


</script>
</body>
</html>